home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
3D Game Programming All in One
/
3D Game Programming All in One Disc.iso
/
3D2E
/
RESOURCES
/
CH5
/
EMAGA5
/
control
/
client
/
misc
/
chatbox.cs
next >
Wrap
Text File
|
2006-09-24
|
1KB
|
46 lines
new MessageVector(MsgBoxMessageVector);
$LastframeTarget = 0;
function onChatMessage(%message, %voice, %pitch)
{
if (GetWordCount(%message)) {
ChatBox.AddLine(%message);
}
}
function onServerMessage(%message)
{
if (GetWordCount(%message)) {
ChatBox.AddLine(%message);
}
}
function ChatBox::addLine(%this,%text)
{
%textHeight = %this.profile.fontSize;
if (%textHeight <= 0)
%textHeight = 12;
%chatScrollHeight = getWord(%this.getGroup().getGroup().extent, 1);
%chatPosition = getWord(%this.extent, 1) - %chatScrollHeight +
getWord(%this.position, 1);
%linesToScroll = mFloor((%chatPosition / %textHeight) + 0.5);
if (%linesToScroll > 0)
%origPosition = %this.position;
while( !chatPageDown.isVisible() && MsgBoxMessageVector.getNumLines() &&
(MsgBoxMessageVector.getNumLines() >= $pref::frameMessageLogSize))
{
%tag = MsgBoxMessageVector.getLineTag(0);
if(%tag != 0)
%tag.delete();
MsgBoxMessageVector.popFrontLine();
}
MsgBoxMessageVector.pushBackLine(%text, $LastframeTarget);
$LastframeTarget = 0;
if (%linesToScroll > 0)
{
chatPageDown.setVisible(true);
%this.position = %origPosition;
}
else
chatPageDown.setVisible(false);
}